<template>
  <div class="user-detail">
    <el-form ref="form" label-width="100px" :model="form" inline>
      <el-form-item
        v-for="item in formLabel"
        :key="item.label"
        :label="item.label"
      >
        <el-input
          v-if="item.type === 'input'"
          :placeholder="'请输入' + item.label"
          v-model="form[item.model]"
        ></el-input>
        <el-switch
          v-if="item.type === 'switch'"
          v-model="form[item.model]"
        ></el-switch>
        <el-date-picker
          v-if="item.type === 'date'"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择日期"
          v-model="form[item.model]"
        ></el-date-picker>
        <el-select
          v-if="item.type === 'select'"
          placeholder="请选择"
          v-model="form[item.model]"
        >
          <el-option
            v-for="el in item.opts"
            :key="el.value"
            :label="el.label"
            :value="el.value"
          ></el-option
        ></el-select>
      </el-form-item>
      <el-form-item>
        <slot></slot>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    form: Object,
    formLabel: Array,
  },
};
</script>

<style lang="less" scoped>
.user-detail {
  form {
    .el-input:nth-child(1) {
      width: 215px;
    }
    .el-form-item:nth-child(5) {
      .el-input {
        width: 567px;
      }
    }
  }
}
</style>
